if exists ( select  *
            from    sys.objects
            where   object_id = object_id(N'[dbo].[twsp_Company_QueryByRewardId]')
                    and type in ( N'P', N'PC' ) ) 
    drop procedure [dbo].twsp_Company_QueryByRewardId
go

create procedure twsp_Company_QueryByRewardId @rewardId int
as 
    select  c.*
    from    dbo.Tb_Reward r
            inner join dbo.Tb_RewardGrant rg on r.rewardId = rg.rewardId
            inner join Tb_Company c on rg.companyId = c.companyId
    where   r.rewardId = @rewardId
	
	
    
go


